////////////////////////////////////////////////////////////////////////////////
//
//  Zemoga Inc
//  Copyright 2011 Zemoga Inc
//  All Rights Reserved.
//
////////////////////////////////////////////////////////////////////////////////
package com.videojukebox.application
{
	import ca.newcommerce.youtube.feeds.VideoFeed;
	
	import com.zemoga.util.youtube.YoutubeSearchVideoProxy;
	
	import flash.events.EventDispatcher;

	/**
	 * This class is the Controller between the visual components and the model data.
	 * Handles all the logic request for the visual components in the application
	 * 
	 * @author	davidnino	<email>
	 */
	public final class AppController extends EventDispatcher
	{
		//------------------------------------------------------------------------------
		//
		//  Constants
		//
		//------------------------------------------------------------------------------
		
		//--------------------------------------
		//  Public
		//--------------------------------------
		
		//--------------------------------------
		//  Private
		//--------------------------------------
		
		//------------------------------------------------------------------------------
		//
		//  Static Methods
		//
		//------------------------------------------------------------------------------

		public static function getInstance():AppController
		{
			if(AppController._instance == null){
				AppController._instance = new AppController(new PrivateClass());
			}
			return AppController._instance;
		}
		
		public static function log(text:String):void
		{
			AppController._instance.application.ta_log.text = AppController._instance.application.ta_log + text + "\n"; 
		}
		
		//------------------------------------------------------------------------------
		//
		//  Static variables
		//
		//------------------------------------------------------------------------------
		
		private static var _instance:AppController;
		////////////////////////////////////////////////////////////////////////////////
		//
		//  Constructor
		//
		////////////////////////////////////////////////////////////////////////////////
		
		public function AppController(pvt:PrivateClass = null)
		{
			
		}
		
		//------------------------------------------------------------------------------
		//
		//  Variables
		//
		//------------------------------------------------------------------------------
		
		//--------------------------------------
		//  Public
		//--------------------------------------
		
		//--------------------------------------
		//  Private
		//--------------------------------------
		private var _application:Main;
		
		//------------------------------------------------------------------------------
		//
		//  Properties (getters/setters)
		//
		//------------------------------------------------------------------------------
		public function get application():Main
		{
			return _application;
		}
		
		public function set application(value:Main):void
		{
			_application = value;
		}
		
		//------------------------------------------------------------------------------
		//
		//  Overriden methods
		//
		//------------------------------------------------------------------------------
		
		//------------------------------------------------------------------------------
		//
		//  Methods
		//
		//------------------------------------------------------------------------------
		
		//--------------------------------------
		//  Public
		//--------------------------------------
		public function log(text:String):void
		{
			_application.ta_log.appendText(text + "\n");
		}
		
		
		public function setVideoSeachResult(data:VideoFeed):void
		{
			application.videoResultList.setVideoSeachResult(data);
		}
	}
}

class PrivateClass {
	
	public function PrivateClass()
	{
		//trace("Private Class");
	}	
}